package main

import (
	"fmt"
	"strings"
)

func main() {

	fmt.Println("请输入明文")
	var i string
	fmt.Scan(&i)
	fmt.Println(jiamm(i))

	fmt.Println("请输入密文")
	var o string
	fmt.Scan(&o)
	fmt.Println(jiemm(o))

//a-z 97-122


}

//加密
func jiamm(a string)string  {
	var sil []rune
	var si []string

	for _,value := range a{
		sil = append(sil,value)
	}

	for i := 0;i<len(sil);i++{
		if sil[i]+5>122{
			sil[i] = sil[i]-26
		}
		si = append(si,string(sil[i]+5))
	}

	return strings.Join(si,"")
}

//解密
func jiemm(a string)string  {

	var sil []rune
	var si []string

	for _,value := range a{
		sil = append(sil,value)
	}

	for i := 0;i<len(sil);i++{
		if sil[i]-5<97{
			sil[i] = sil[i]+26
		}
		si = append(si,string(sil[i]-5))
	}

	return strings.Join(si,"")

}
